package com.s7.network.server;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.http.HeaderMap;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;

/**
 * 文件上传服务
 */
public interface FileServer {

    /**
     * 上传文件
     * @param url
     * @param parameters 参数
     * @param file  UploadFileRequestBody upload = new UploadFileRequestBody(
     *                RequestBody.create(MediaType.parse("multipart/form-data"), new File(path)), listener);
     * @return
     */
    @Multipart
    @POST
    Observable<ResponseBody> uploadFile(@Url String url,
                                        @QueryMap Map<String, String> parameters,
                                        @Part MultipartBody.Part file);

    /**
     * 上传文件
     * @param url
     * @param headers 请求头
     * @param parameters 参数
     * @param file   UploadFileRequestBody upload = new UploadFileRequestBody(
     *                 RequestBody.create(MediaType.parse("multipart/form-data"), new File(path)), listener);
     * @return
     */
    @Multipart
    @POST
    Observable<ResponseBody> uploadFile(@Url String url,
                                        @HeaderMap Map<String, String> headers,
                                        @QueryMap Map<String, String> parameters,
                                        @Part MultipartBody.Part file);

}
